﻿using System;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = int.Parse(Console.ReadLine());
        }
        int index = 0;
        int count = 1;
        int most;
        int times=0;
        for (int i = 1; i < n; i++)
        {
            if (arr[i] == arr[index])
            {
                count++;
            }
            else
            {
                count--;
            }
            if (count == 0)
            {
                count = 1;
                index = i;
                times++;
            }
        }
        most = arr[index];
        Console.WriteLine(most);
        Console.WriteLine(times);
    }
}